#include <iostream>

using namespace std;
bool check(int n) {
    while (n) {
        if (n % 10 != 4 && n % 10 != 7)
            return false;
        n /= 10;
    }
    return true;
}
int main()
{
    int n;
    int ret = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (check(i))
            ret++;
    }
    cout << ret;
    return 0;
}
//100-6 1000 14  10000 30